from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from tools.myLogger import logger

class BaseAPP():

    def __init__(self, driver):
        logger.info("初始化app-driver")
        self.driver = driver
        # self.driver = webdriver.Remote()
        self.driver.implicitly_wait(20)

    def my_find_element(self, ele):
        logger.info(f"查找元素，元素定位表达式为：{ele}")
        self.ele = self.driver.find_element(*ele)

    def my_click(self, ele):
        self.my_find_element(ele)
        self.ele.click()

    def my_send(self, ele, value):
        self.my_find_element(ele)
        self.ele.clear()
        self.ele.send_keys(value)

    def my_get_text(self, ele):
        self.my_find_element(ele)
        return self.ele.text

    def my_start_app(self, package, activity):
        self.driver.start_activity(package, activity)
